<template>
	<view class="myMembers">
		<view class="membersList" v-for="(item, index) in listData" :key="index">
			<image class="userHead" :src="item.avatar" mode="widthFix"></image>
			<view class="userInfo">
				<view class="userName">
					{{item.nickname}}
				</view>
				<view class="time">
					{{item.add_time}}
				</view>
			</view>
			<view class="userBtn notReceived rtl">
				{{item.brokerage}}{{"元"|i18n}}
			</view>
		</view>
	</view>
</template>

<script>
	import { userSpreadPeople } from '@/api/dailyLife.js';
	export default {
		data() {
			return {
				listData: [],
				page: 1,
				isLoadMore: false
			};
		},
		methods: {
			async loadData() {
				uni.showLoading({
					title: ''
				});
				try{
					let resData = await userSpreadPeople({
						page: this.page
					})
					if (resData.data.length) {
						this.listData = [...this.listData, ...resData.data]
						this.isLoadMore = false
					} else {
						this.isLoadMore = true
					}
					uni.hideLoading();
				}catch(e){
					if(this.page > 1){
						this.page-=1
					}
					console.log(e);
					this.isLoadMore = false
					uni.hideLoading();
				}
			}
		},
		onLoad() {
			this.loadData()
		},
		onReachBottom() {
			if (!this.isLoadMore) {
                this.isLoadMore = true
                this.page+=1
				this.loadData();
			}
		}
	}
</script>

<style lang="scss">
	.myMembers {
		min-height: 100vh;
		background-color: #fff;
		padding: 30rpx 30rpx 0;
		.membersList {
			margin-bottom: 40rpx;
			display: flex;
			align-items: center;
			.userHead {
				width: 90rpx;
				height: 90rpx;
				border-radius: 500%;
			}
			.userInfo {
				flex: 1;
				padding: 10rpx 20rpx;
				display: flex;
				flex-wrap: wrap;
				align-content: space-between;
				.userName {
					width: 100%;
					font-size: 32rpx;
					font-weight: 500;
					color: #333333;
				}
				.time {
					width: 100%;
					font-size: 22rpx;
					font-weight: 400;
					color: #999999;
				}
			}
			.userBtn {
				width: 130rpx;
				height: 48rpx;
				line-height: 48rpx;
				text-align: center;
				font-size: 24rpx;
				font-weight: 400;
				color: #333333;
				border-radius: 8rpx;
			}
			.received {
				background: #F5F5F5;
			}
			.notReceived {
				background: #FBD246;
			}
		}
	}
</style>
